<template>
  <div class="home">
    <!-- 头部 -->
    <FloorHeader :title="data.name" :cates="data.subCateList" :link="$t('seeMore')"/>
    <!-- 轮播图 -->
    <Swiper class="swiper-container">
      <SwiperItem v-for="item in data.indexFocus" :key="item.id">
        <img :src="item.picUrl" :alt="item.name">
      </SwiperItem>
    </Swiper>
    <!-- 商品列表 -->
    <div class="goods-list">
      <div class="goods" v-for="item in data.itemList" :key="item.id">
        <img :src="item.listPicUrl" :alt="item.name">
        <!-- 商品标签 -->
        <div class="tips">
          <div class="tip" :class="{ hot: tag.type === 0 }" v-for="tag in item.itemTagList" :key="tag.tagId">{{ tag.name }}</div>
        </div>
        <!-- 商品名称 -->
        <div class="name">{{ item.name }}</div>
        <!-- 商品价格 -->
        <div class="price">
          {{ $t('priceSymbol') }}{{ item.retailPrice }}
          <span class="cost" v-if="item.counterPrice > 0">{{ $t('priceSymbol') }}{{ item.counterPrice }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import FloorHeader from '@/components/index/FloorHeader'

export default {
  props: {
    data: {
      type: Object,
      default: () => {}
    }
  },

  components: {
    FloorHeader
  }
}
</script>

<style lang="less" scoped>
@import "../../styles/variable";
@import "../../styles/common";

.home {
  background: @write;
  padding: 60px 0px;
  .swiper-container {
    height: 310px;
  }
  .goods-list {
    margin-top: 20px;
    overflow: hidden;
    .goods {
      float: left;
      padding: 0px 10px 50px 0px;
      width: 25%;
      overflow: hidden;
      img {
        .transition;
        width: 100%;
        height: 265px;
        margin-bottom: 8px;
        &:hover {
          transform: scale(1.02, 1.02);
        }
      }
      .tips {
        text-align: center;
        height: 20px;
        margin-bottom: 4px;
        .tip {
          background-color: @bg-tips;
          color: @write;
          display: inline-block;
          font-size: 12px;
          height: 20px;
          line-height: 20px;
          padding: 0 5px;
          &.hot {
            background-color: @font-color-tag-warning;
          }
        }
      }
      .name {
        color: @font-color;
        font-weight: 600;
        font-size: 14px;
        margin-bottom: 4px;
        height: 20px;
        line-height: 20px;
        text-align: center;
      }
      .price {
        font-size: 13px;
        line-height: 13px;
        color: @color-warning;
        padding: 1px 0 9px;
        margin: 0;
        text-align: center;
        .cost {
          color: #999;
          font-size: 12px;
          text-decoration: line-through;
        }
      }
      &:last-child {
        padding-right: 0px;
      }
    }
  }
}
</style>
